<template>
  <el-breadcrumb separator="/">
    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item v-for="item in pathItem">
      {{item}}
    </el-breadcrumb-item>
  </el-breadcrumb>
</template>
<script setup>
import {useRoute} from 'vue-router'
import {useWmsGlobal} from '@/store/wmsGlobal'
import { reactive,computed } from 'vue'
const wmsGlobal = useWmsGlobal();
const router = useRoute();
const pathItem = computed(()=>{
  if(router.path === '/'){
    return []
  }
  const arr = router.path.split('/')
  arr.splice(0,1)
  return arr.map(value=>{
    const obj = wmsGlobal.menuData.find((item)=>{
      const reg = new RegExp(`\/${value}$`)
      if(reg.test(item.url)){
        return item
      }
    })
    return obj ? obj.menu_name:null
  })
})

</script>
